package contacts530.application;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author Dell-
 */
public class Delete {
 Connection ct;
    PreparedStatement ps;
    public Delete(String name) {
         try {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        String url = "jdbc:sqlserver://localhost;database =contactsdb;user=sa;password=zyn416427";
        ct = DriverManager.getConnection(url);
                ps = ct.prepareStatement("delete from student where name=?");
                ps.setString(1,name);
                ps.executeUpdate();

            } catch (ClassNotFoundException | SQLException e1) {
                System.out.println("ERROR:"+e1);
            } finally {
                try {
                    if (ps != null) {
                        ps.close();
                    }
                    if (ct != null) {
                        ct.close();
                    }
                } catch (SQLException e2) {

                }
            }
    }
    
}
